﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Services.Contracts.DTO.Infos;
using Demo.Services.Services.Impl.DomainObjects;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;
using Demo.Services.Contracts.DTO.Filters;
using Demo.CommonBase.DTO.Infos;

namespace Demo.Services.Services.Impl.Managers
{
    public class ResourceTypeManager
    {
        public ResourceTypeResultInfo GetResourceTypes(PaginationInfo pagin, ResourceTypeFilter filters)
        {
            ResourceTypeResultInfo result = null;
            ResourceTypeDomainObject resourceTypeDO;
            try
            {
                //Logger.Info();
                resourceTypeDO = new ResourceTypeDomainObject();
                result = resourceTypeDO.GetResourceTypes(pagin, filters);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
                
            }
            return result;
        }
        public void SaveResourceType(ResourceTypeInfo info)
        {

            ResourceTypeDomainObject resourceTypeDO;
            try
            {
                //Logger.Info();
                resourceTypeDO = new ResourceTypeDomainObject();
                resourceTypeDO.SaveResourceType(info);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public void DeleteResourceType(int id)
        {
            ResourceTypeDomainObject resourceTypeDO;
            try
            {
                //Logger.Info();                
                resourceTypeDO = new ResourceTypeDomainObject();
                resourceTypeDO.DeleteResourceType(id);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public List<ResourceTypeInfo> GetList()
        {
            ResourceTypeDomainObject resourceTypeDO;
            List<ResourceTypeInfo> result;
            try
            {
                //Logger.Info();
                resourceTypeDO = new ResourceTypeDomainObject();
                result = resourceTypeDO.GetList();
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }


        public ResourceTypeInfo GetResourceTypeById(int id)
        {
            ResourceTypeInfo result = null;
            ResourceTypeDomainObject resourceTypeDO;
            try
            {
                //Logger.Info();                
                resourceTypeDO = new ResourceTypeDomainObject();
                result = resourceTypeDO.GetResourceTypeById(id);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        public bool CheckName(int id, string name)
        {
            bool isValid = false;
            ResourceTypeDomainObject resourceTypeDO;
            try
            {
                Logger.Info();
                resourceTypeDO = new ResourceTypeDomainObject();
                isValid = resourceTypeDO.CheckName(id, name);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return isValid;
        }
    }
}
